Question: 1 -
Which of the below is not a Java Profiler?
-
JProfiler
-
JVM
-
Eclipse Profiler
-
JConsole
Answer:
JVM
Solution:
Memory leak is like holding a strong reference to an object although it would never be needed anymore. Objects that are reachable but not live are considered memory leaks. Various tools help us to identify memory leaks.
Memory leak is like holding a strong reference to an object although it would never be needed anymore. Objects that are reachable but not live are considered memory leaks. Various tools help us to identify memory leaks.
Question: 2 -
How to get prints of shared object memory maps or heap memory maps for a given process?
-
jmap
-
memorypath
-
memorymap
-
jvmmap
Answer:
jmap
Solution:
We can use jmap as jmap -J-d64 -heap pid.
We can use jmap as jmap -J-d64 -heap pid.
Question: 3 -
What is -Xms and -Xmx while starting jvm?
-
Maximum; Initial memory
-
Maximum memory
-
Initial memory
-
Initial; Maximum memory
Answer:
Initial; Maximum memory
Solution:
JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. java -Xmx2048m -Xms256m.
JVM will be started with Xms amount of memory and will be able to use a maximum of Xmx amount of memory. java -Xmx2048m -Xms256m.
Question: 4 -
Which of the below is not a memory leak solution?
-
JVM parameter tuning
-
GC parameter tuning
-
Code changes
-
Process restart
Answer:
Process restart
Solution:
Process restart is not a permanent fix to memory leak problem. The problem will resurge again.
Process restart is not a permanent fix to memory leak problem. The problem will resurge again.
Question: 5 -
What allows the programmer to destroy an object x?
-
Runtime.getRuntime().gc()
-
x.finalize()
-
Only the garbage collection system can destroy an object
-
x.delete()
Answer:
Only the garbage collection system can destroy an object
Solution:
When an object is no longer referenced, it may be reclaimed by the garbage collector. If an object declares a finalizer, the finalizer is executed before the object is reclaimed to give the object a last chance to clean up resources that would not otherwise be released. When a class is no longer needed, it may be unloaded.
When an object is no longer referenced, it may be reclaimed by the garbage collector. If an object declares a finalizer, the finalizer is executed before the object is reclaimed to give the object a last chance to clean up resources that would not otherwise be released. When a class is no longer needed, it may be unloaded.